package com.java2007.service.impl;

import com.java2007.mapper.ReaderCardMapper;
import com.java2007.pojo.ReaderCard;
import com.java2007.service.ReaderCardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author zy
 * @version V1.0
 * @date 2021/03/10
 */
@Service
@Transactional
public class ReaderCardServiceImpl implements ReaderCardService {
    @Autowired
    private ReaderCardMapper readerCardMapper;

    @Override
    public ReaderCard login(String readerName, String password) {
        ReaderCard readerCard = readerCardMapper.findByReaderName(readerName);
        if (readerCard != null){
            if (readerCard.getPassword().equals(password)) {
                return readerCard;
            } else {
                throw new RuntimeException("账户或密码错误！！！");
            }
        } else {
            throw new RuntimeException("账户不存在，请联系管理员！");
        }
    }


}
